<template>
  <div class="avue-top">
    <div class="top-bar__left">
      <div class="avue-breadcrumb" v-if="showCollapse">
        <i class="icon-navicon" @click="setCollapse"></i>
        <span style="font-size: 16px; margin-left: 10px"
          >瑞铺-管理后台</span
        >
      </div>
    </div>
    <div class="top-bar__title">
      <div class="top-bar__item top-bar__item--show" v-if="showMenu">
        <top-menu></top-menu>
      </div>
    </div>
    <div class="top-bar__right">
      <!-- <div class="bell" @click="goNotice">
        <span>{{ adminMessageNum }}</span>
        <i class="el-icon-message-solid el-icon--right"></i>
      </div> -->
      <el-tooltip
        v-if="showLock"
        effect="dark"
        content="锁屏"
        placement="bottom"
      >
      </el-tooltip>
      <el-tooltip
        v-if="showFullScren"
        effect="dark"
        :content="isFullScreen ? '退出全屏' : '全屏'"
        placement="bottom"
      >
        <div class="top-bar__item">
          <i
            :class="isFullScreen ? 'icon-zuixiaohua' : 'icon-quanpingzuidahua'"
            @click="handleScreen"
          ></i>
        </div>
      </el-tooltip>
      <el-dropdown>
        <span class="el-dropdown-link">
          {{ userInfo.username }}
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <router-link to="/">首页</router-link>
          </el-dropdown-item>
          <el-dropdown-item>
            <router-link to="/info/index">修改密码</router-link>
          </el-dropdown-item>
          <el-dropdown-item @click.native="logout" divided
            >退出系统
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
import { fullscreenToggel, listenfullscreen } from "@/util/util";
import topMenu from "./top-menu";

export default {
  components: {
    topMenu
  },
  name: "top",
  data() {
    return {};
  },
  filters: {},
  created() {},
  mounted() {
    listenfullscreen(this.setScreen);
  },
  computed: {
    ...mapState({
      showLock: state => state.common.showLock,
      showFullScren: state => state.common.showFullScren,
      showCollapse: state => state.common.showCollapse,
      showMenu: state => state.common.showMenu
    }),
    ...mapGetters([
      "userInfo",
      "isFullScreen",
      "tagWel",
      "tagList",
      "isCollapse",
      "tag",
      "logsLen",
      "logsFlag",
      "adminMessageNum"
    ])
  },
  methods: {
    handleScreen() {
      fullscreenToggel();
    },
    setCollapse() {
      this.$store.commit("SET_COLLAPSE");
    },
    setScreen() {
      this.$store.commit("SET_FULLSCREN");
    },
    logout() {
      this.$confirm("是否退出系统, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.$store.dispatch("LogOut").then(() => {
          this.$router.push({ path: "/login" });
          window.location.reload()
        });
      });
    },
    goNotice() {
      this.$router.push({ path: "/wel/notice" });
    }
  }
};
</script>

<style lang="scss" scoped>
.avue-breadcrumb {
  display: flex;
  align-items: center;
}
.bell {
  margin-right: 10px;
  cursor: pointer;
  position: relative;
  span {
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background-color: red;
    font-size: 10px;
    line-height: 15px;
    text-align: center;
    top: 10px;
    right: -5px;
    color: white;
  }
  i {
    font-size: 20px;
    line-height: 1;
  }
}
</style>
